package com.supermap.dataservice.project.cq.agri;

import com.alibaba.dubbo.config.annotation.Service;
import com.supermap.dataservice.mysql.config.DynamicDataSourceContextHolder;
import com.supermap.dataservice.project.template.ProductTemplateMapper;
import com.supermap.dubbo.api.cq.product.agri.AgriProduct;
import com.supermap.dubbo.api.cq.product.agri.AgriProductService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author aqua
 * @description
 * @date 2018年11月12 下午 5:07
 * @email 1301584033@qq.com
 */
@Service
public class AgriProductServiceImpl implements AgriProductService {

    @Resource
    private ProductTemplateMapper productTemplateMapper;
    @Resource
    private AgriProductMapper agriProductMapper;
    @Override
    public List<AgriProduct> getAgriProductTimeDesc(String areaCode,String pageSize) {
        // 切换数据源
        DynamicDataSourceContextHolder.setDataSourceKey("ds1");
        List<AgriProduct> productList=productTemplateMapper.
                ggetListProductTemplateAgriProduct();
        for (AgriProduct agriProduct:productList){
            agriProduct.setMapList(agriProductMapper.
                    getAgriProductTimeDesc(agriProduct.getTemplateId(),areaCode,Integer.valueOf(pageSize)));
        }
        return productList;
    }
}
